package com.wuyou.mybatishandlerdemo.controller;

import com.wuyou.mybatishandlerdemo.component.EmailComponent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import java.util.Properties;

/**
 * EmailController
 *
 * @Date 2025-09-26 13:25
 * @Author 无忧
 */
@RestController
@RequestMapping(value = "/email")
public class EmailController {


    @Autowired
    private EmailComponent emailComponent;


    /**
     * 发送测试邮件
     */
    @GetMapping("/test/{msg}")
    public String sendTestEmail(@PathVariable(name = "msg") String to) {
            emailComponent.sendSimpleEmail(to, "测试邮件 - IMelter企业邮箱",
                    "这是一封来自 yh.zhang@imelter.com 的测试邮件！\n\n" +
                            "发送时间: " + new java.util.Date());
            return "邮件发送成功到: " + to;
    }

}
